<?php session_start(); ?>

<?php

include "Connect.php";

$_SESSION['xx']="";

$del = @$_POST['del'];

@$see = $_SESSION['see'] = $_POST['see'];

if (isset($_GET['page'])){
$page = $_GET['page']; 
MC();
}
/*if($see){
$_SESSION['xx'] = "";
MC();

}*/

function MC(){

if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; 

$_SESSION['mG'] = 1;

$max_results = 10;

$from = (($page * $max_results) - $max_results);
 
$getStuff = mysql_query("SELECT * FROM processedorder LIMIT $from, $max_results") or die(mysql_error());
include "processedorders.php";

}

if(isset($del)){
$checkbox=@$_POST['checkbox'];
if($checkbox == null){
$_SESSION['xx'] = "Please select atleast an item to delete!!";
$_SESSION['mande'] = "";
MC();
}else{
$getD = mysql_query("SELECT * FROM processedorder");
for($i=0;$i<mysql_num_rows($getD);$i++){
$del_id = @$checkbox[$i];
$sql = "DELETE FROM processedorder WHERE ID ='$del_id'";
$result = mysql_query($sql);
}
if($result){
MC();
}

  }
     }

/*if(isset($del)){

$checkbox=$_POST['checkbox'];

for($i=0;$i<count($checkbox);$i++){
$del_id = $checkbox[$i];

$sql = "DELETE FROM processedorder WHERE ID ='$del_id' ";
$result = mysql_query($sql); 

}

if($result){
MC();
//echo count($del_id)." record(s) deleted";

}else{

$msg2 =  "Delete failed, Please try again!!";
header("location:adminPage.php?poll2=$msg2");
MC();
}

  }*/
   

?>